package com.qf.day13;

import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.TreeSet;

public class TreeSetDemo {
    public static void main(String[] args) {
        Student student1=new Student("王酩盛",28);
        Student student2=new Student("王酩盛",28);
        Student student3=new Student("王青衣",27);
        TreeSet<Student>treeSet=new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int num=o1.getAge()- o2.getAge();
                return num;
            }
        });
        treeSet.add(student1);
        treeSet.add(student2);
        treeSet.add(student3);
        System.out.println(treeSet);
        LinkedHashSet<Student>linkedHashSet=new LinkedHashSet<>();
        linkedHashSet.add(student1);
        linkedHashSet.add(student2);
        linkedHashSet.add(student3);
        System.out.println(linkedHashSet);
    }
}
